package com.anzia.demo05;

/**
 *@ClassName TestStudent
 *@Description
 *@Author Anzia.
 *@Date 2021/4/11 12:54
 *@Version 1.0
 **/
public class TestStudent {
    public static void main(String[] args) {
        Student student1 = new Student("aaa", 11);
        Student student2 = new Student("bbb", 12);

        //判断1he2是不是同一个类型
        Class<? extends Student> aClass1 = student1.getClass();
        Class<? extends Student> aClass2 = student2.getClass();
        System.out.println("-----------------");
        if (aClass1 == aClass2) {
            System.out.println("同类型");
        } else {
            System.out.println("不同类型");
        }

        //hashCode方法
        System.out.println("-----------------");
        System.out.println(student1.hashCode());
        System.out.println(student2.hashCode());
        Student student3 = student1;
        System.out.println(student3.hashCode());

        //toString方法
        System.out.println("-----------------");
        System.out.println(student1.toString());
        System.out.println(student2.toString());

        //equals方法，判断两个对象是否相等
        System.out.println("-----------------");
        System.out.println(student1.equals(student2));
        System.out.println(student1.equals(student3));
        Student student4 = new Student("小明", 22);
        Student student5 = new Student("小明", 22);
        System.out.println(student4.equals(student5));


    }
}
